#pragma once

#include <vld.h>

#include "clkHeader.h"
#include "clkMath.h"

#include "clkGrid.h"
#include "clkContact.h"
#include "clkObject.h"
#include "clkObjectDef.h"

class clkWorld
{
private:
	clkGrid m_grid;
	clkAABB m_cull;
	List<clkContact> m_conList;
	List<clkObject*> m_objList;
	List<clkObject*> m_objQueue;
	MemPool<clkObject>  m_objPool;
public:
	clkWorld();
	~clkWorld();

	void init(float a_cWidth, float a_cHeight);
	void destroy();

	void cullBox(V2DF a_min,V2DF a_max);
	void updatePhysics(float a_time, int a_iter = 1);
	void generateContacts(float a_time, int a_iter = 1);
	void resolveContacts(float a_time, int a_iter = 1);

	clkObject* createObject(clkObjectDef& a_objDef);
	void destroyObject(clkObject* a_object);

	void pullObject(clkObject* a_object);
	void waitObject(clkObject* a_object);

	List<clkObject*>* getList(){return &m_objList;}
};